# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=cilium-cli
pkgver=0.16.6
pkgrel=0
pkgdesc="CLI to install, manage and troubleshoot Kubernetes clusters running Cilium"
url="https://cilium.io/"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/cilium/cilium-cli/archive/refs/tags/v$pkgver.tar.gz
	byteorder-add-s390x-support.patch
	"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v \
		-ldflags "-X github.com/cilium/cilium-cli/internal/cli/cmd.Version=v$pkgver" \
		./cmd/cilium

	for shell in bash fish zsh; do
		./cilium completion $shell > cilium.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 cilium -t "$pkgdir"/usr/bin/

	install -Dm644 cilium.bash \
		"$pkgdir"/usr/share/bash-completion/completions/cilium
	install -Dm644 cilium.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/cilium.fish
	install -Dm644 cilium.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_cilium
}

sha512sums="
8c62877c58b9a3d855d5edc4f89a1f525ebb7ab1863df73e9106ad6fbca7536ba3b8d85e4f5a86f8fbde873b53fd23ff3389179b247f4c7aaad6bbaa18fba773  cilium-cli-0.16.6.tar.gz
872ccb44ac714420f87c476743d7be1b644c3a5c7e2a975d47720dc970c632ce82bb678421b053ebbc219d4a3b1f2c9f37aa74f3733a055b0f8c1dbe15fed23f  byteorder-add-s390x-support.patch
"
